package com.hq.tintdemo;

import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        LinearLayout parent = (LinearLayout) findViewById(R.id.root);

        List<PorterDuff.Mode> modeList = new ArrayList<>();
        modeList.add(PorterDuff.Mode.CLEAR);
        modeList.add(PorterDuff.Mode.SRC);
        modeList.add(PorterDuff.Mode.DST);
        modeList.add(PorterDuff.Mode.SRC_OVER);
        modeList.add(PorterDuff.Mode.DST_OVER);
        modeList.add(PorterDuff.Mode.SRC_IN);
        modeList.add(PorterDuff.Mode.DST_IN);
        modeList.add(PorterDuff.Mode.SRC_OUT);
        modeList.add(PorterDuff.Mode.DST_OUT);
        modeList.add(PorterDuff.Mode.SRC_ATOP);
        modeList.add(PorterDuff.Mode.DST_ATOP);
        modeList.add(PorterDuff.Mode.XOR);
        modeList.add(PorterDuff.Mode.ADD);
        modeList.add(PorterDuff.Mode.MULTIPLY);
        modeList.add(PorterDuff.Mode.SCREEN);
        modeList.add(PorterDuff.Mode.OVERLAY);
        modeList.add(PorterDuff.Mode.DARKEN);
        modeList.add(PorterDuff.Mode.LIGHTEN);

        int tintColor = Color.parseColor("#479eb6");

        for (int i = 0; i < modeList.size(); i++) {
            PorterDuff.Mode mode = modeList.get(i);

            TextView textView = new TextView(this);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f);
            textView.setTextColor(Color.BLACK);
            textView.setText(mode.toString());
            textView.setPadding(0, 30, 0, 10);

            ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            parent.addView(textView, params);

            ImageView imageView = new ImageView(this);
            imageView.setImageResource(R.mipmap.tabbar_profile);
            imageView.setColorFilter(tintColor, mode);

            parent.addView(imageView, params);
        }

    }
}
